home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Games Collection 1
/
software vault.zip
/
software vault
/
CDR10
/
SPX20.ZIP
/
SPX_DOC.ZIP
/
SPX_INI.DOC
< prev
next >
Wrap
Text File
|
1993-09-15
|
5KB
|
115 lines
{ SPX Library Version 2.0 Copyright 1993 Scott D. Ramsay }
SPX_INI is the customization unit. It allows you to create and maintain
custom .INI text files for use in your programs.
You can put comments in the file by specifying a semi-colon at the
begining of the line. To define a value you specify a key name then
what it equals then its value.
KeyName=[value]
Key names are case in-sensitive. Values and key names can be anything
other than spaces.
Below is a sample .INI file:
; My Custom ini file for my sample Game
;
Players=4
BackGroundColor=0
StartX=160
StartY=100
; Computer level 1-Easy 4-Hard
ComputerLevel=2
; High Score
HighScore=39381
───────────────────────────────────────────────────────────────────────────
Error return codes
The following are values that are returned after a call to each function
ini_noerror = 0; { no error }
ini_notexist = 1; { ini file does not exist }
ini_nokeyname = 2; { ini file does not contain key }
ini_errorsave = 3; { error writing data }
ini_errorload = 4; { error readding data }
ini_errupdate = 5; { error updating ini file }
───────────────────────────────────────────────────────────────────────────
function getIniInt(fileName,keyName:string;default:integer;var returned:integer):integer;
Get an integer value from the INI file
FILENAME: The file name of the ini file. If FileName does not specify
an extension, .INI is automatically added. FileName can have
a path. If not found, it will search for the file in the
same directory as the executed program.
KEYNAME: The keyName to to read
DEFAULT: A default integer to return if KeyName does not exist.
RETURNED: The returned value of the keyname
Returns an ini return code.
EXAMPLE:
var
HiScore : integer;
getIniInt('myini.ini','HighScore',0,HiScore);
{ searches for the key name HighScore, if not found the HiScore
variable is set to zero }
───────────────────────────────────────────────────────────────────────────
function getIniString(fileName,keyName,default:string;var returned:string):integer;
Same as getIniInt. Get a string value from the INI file
FILENAME: The file name of the ini file. If FileName does not specify
an extension, .INI is automatically added. FileName can have
a path. If not found, it will search for the file in the
same directory as the executed program.
KEYNAME: The keyName to read
DEFAULT: A default string to return if KeyName does not exist.
RETURNED: The returned value of the keyname
───────────────────────────────────────────────────────────────────────────
function setIniInt(fileName,keyName:string;value:integer):integer;
Set an integer value to the INI file
FILENAME: The file name of the ini file. If FileName does not specify
an extension, .INI is automatically added. FileName can have
a path. If not found, it will create the INI file in the same
directory as the executed program.
KEYNAME: The keyName to change. If the key name does not exist in the
file, it is automatically added to the end of the file
VALUE: The value to set to keyName
───────────────────────────────────────────────────────────────────────────
function setIniString(fileName,keyName,value:string):integer;
Same as setIniInt. Set a string value to the INI file
FILENAME: The file name of the ini file. If FileName does not specify
an extension, .INI is automatically added. FileName can have
a path. If not found, it will create the INI file in the same
directory as the executed program.
KEYNAME: The keyName to change. If the key name does not exist in the
file, it is automatically added to the end of the file
VALUE: The value to set to keyName. if value is an empty string,
then the keyName is removed from the file.
───────────────────────────────────────────────────────────────────────────
The SPX_INI unit will save the changes when your program exits to minimize
disk access. It maintains all key names and variables in memory so you
can do multiple GetIni's and SetIni in any combination. It can also maintain
multiple INI files and write to all of them to disk at the end of the
program.